package com.bac.rentmap.web.controller.osmimport;

import com.bac.rentmap.manager.BuildingManager;
import com.bac.rentmap.manager.StreetManager;
import com.bac.rentmap.model.Building;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.validation.BindException;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 *
 * @author Ivan Holub
 */
public class ClearStreetsServiceController extends AbstractController {

    private StreetManager streetManager;

    public void setStreetManager(StreetManager streetManager) {
        this.streetManager = streetManager;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {

        String numberParam = httpServletRequest.getParameter("number");
        int number = Integer.valueOf(numberParam);

        streetManager.clearStreets(number);

        int maxNumber = streetManager.getMaxNumber();
        ModelAndView mav = new ModelAndView("admin/import/osm/clearstreetsservice");
        mav.addObject("maxNumber", maxNumber);
        return mav;
    }
}